Fix cloud app hanging on Cloudflare Workers - #121
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
executor-marketing | 7b3632f | Commit Preview URL Branch Preview URL |
Apr 09 2026, 12:12 AM |
- Use pg.Client instead of pg.Pool (Hyperdrive manages pooling) - Remove Layer.memoize/Scope at module top level (hangs in Workers init) - Make public API handler lazy - Remove debug endpoint
RhysSullivan
force-pushed
the
fix-cloud-workers-db
branch
from
April 9, 2026 00:10
801b118 to
7b3632f
Compare
RhysSullivan
added a commit
that referenced
this pull request
May 31, 2026
- Use pg.Client instead of pg.Pool (Hyperdrive manages pooling) - Remove Layer.memoize/Scope at module top level (hangs in Workers init) - Make public API handler lazy - Remove debug endpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pg.Clientinstead ofpg.Pool— Hyperdrive manages connection pooling externallyEffect.runSync(Scope.make())andLayer.memoizeat module top level — this pattern holds resources across the module lifecycle which causes the DB connection to hang during Workers' restricted init contextRoot cause
Layer.memoizewith a top-levelScopeattempted to establish and hold a DB connection during module initialization. Workers restrict I/O during init, causing the connection to hang indefinitely and triggering "Worker's code had hung" errors.Test plan
/api/auth/mereturns 401 (no hang)/api/auth/loginredirects to WorkOS with HTTPS callback URL/api/debug/dbconfirmed Hyperdrive → Planetscale connection works